<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="<%=basePath %>css/pagination.css">
        <link rel="stylesheet" href="<%=basePath %>css/cssreset.css">
        
        <link rel="stylesheet" href="<%=basePath %>css/style2.css">
		<script src="<%=basePath %>js/jquery-1.11.1.min.js"></script>
		<script language="javascript" src="<%=basePath %>js/PCASClass.js"></script>
		<script>
		       $(function(){
			    	$(".newkh").click(function(e){
			        e.preventDefault();
			        $("#cover").css("display","block");
			        $("#cover").animate({
			            width: "100%",
			            height: "1800px",
			            top: "0",
			            left: "0"
			        },10);
			        
			    });
			    $(".close").click(function(){
			        $("#cover").removeAttr("style");
			        $("#cover-content").removeAttr("style");
			    });
			    $(".newsale").click(function(e){
			        e.preventDefault();
			        $("#cover3").css("display","block");
			        $("#cover3").animate({
			            width: "100%",
			            height: "1800px",
			            top: "0",
			            left: "0"
			        },10);
			        
			    });
			    $(".close").click(function(){
			        $("#cover3").removeAttr("style");
			        $("#cover-content2").removeAttr("style");
			    });
			    $(".newht").click(function(e){
			        e.preventDefault();
			        $("#cover4").css("display","block");
			        $("#cover4").animate({
			            width: "100%",
			            height: "1800px",
			            top: "0",
			            left: "0"
			        },10);
			        
			    });
			    $(".close").click(function(){
			        $("#cover4").removeAttr("style");
			        $("#cover-content3").removeAttr("style");
			    });
			    /*第一个表的隐藏与显示*/
			    $('.check1').click(function(event) {
			    	
			    	$('.checkok').css('display', 'block');
			    	$('.del').css('display', 'block');
			    	$('.shift').css('display', 'block');
			    	$('.close2').css('display', 'block');
			    });
			    $('.close2').click(function(event) {
			    	$('.back').css('display', 'block');
			    	$('#smallig').css('display', 'block');
			    	$('.smalltitle p').css('display', 'block');
			    	$('.checkok').css('display', 'none');
			    	$('.del').css('display', 'none');
			    	$('.shift').css('display', 'none');
			    	$('.close2').css('display', 'none');
			    });
			    /*第二个表的隐藏与显示*/
			    $('.ccheck1').click(function(event) {
			    	
			    });
			    $('.cclose2').click(function(event) {
			    	$('.back2').css('display', 'block');
			    	$('#smallig').css('display', 'block');
			    	$('.smalltitle3 p').css('display', 'block');
			    	$('.checkok2').css('display', 'none');
			    	$('.del2').css('display', 'none');
			    	$('.shift2').css('display', 'none');
			    	$('.cclose2').css('display', 'none');
			    });
			    /*第三个表的隐藏与显示*/
			    $('.check3').click(function(event) {
			    	
			    	$('.checkok3').css('display', 'block');
			    	$('.del3').css('display', 'block');
			    	$('.shift3').css('display', 'block');
			    	$('.close4').css('display', 'block');
			    	
			    });
			    $('.close4').click(function(event) {
			    	$('.back3').css('display', 'block');
			    	$('#smallig').css('display', 'block');
			    	$('.smalltitle4 p').css('display', 'block');
			    	$('.checkok3').css('display', 'none');
			    	$('.del3').css('display', 'none');
			    	$('.shift3').css('display', 'none');
			    	$('.cclose3').css('display', 'none');
			    });
			});
		</script> 
		
		<script>
		  	
       	function selectCheck(){
	    	   var judge = $("#selectCheck").val();
	    	   var objs = document.getElementsByName("items");
			   if(judge == 1){
				   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = true;
		    	   }
				   $("#selectCheck").val(0);
	    	   }else{
	    		   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = false;
		    	   }
	    		   $("#selectCheck").val(1);
	    	   }
	    	   
	    	   checkedShow();
	       }
		  	
		function checkedShow(){
		  		var str = "";
	    	    var number = 0;
	    	    var obj = document.getElementsByName("items");
				for(var i = 0,l = obj.length;i < l;i++){
					if(obj[i].checked){
						str += obj[i].value+",";
						number++;
					}
				}    	   
	    			
	    	    if(str == ""){
	    	       $('.back').css('display', 'block'); 
	    		   $(".show2").hide();
	    		   $('.smalltitle p').css('display', 'block');
	    	    }else{
	    	       $('.smalltitle p').css('display', 'none');
	    		   $(".client_id").html(str);
	    		   $(".show2").show();
	    		   $("#number").html(number);
	    		   
	    		   $('.back').css('display', 'none'); 
	    	   }
		  	}
		  	 
		  </script>
		  
		  <script>
		  	
       	function selectCheck1(){
	    	   var judge = $("#selectCheck1").val();
	    	   var objs = document.getElementsByName("item1");
			   if(judge == 1){
				   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = true;
		    	   }
				   $("#selectCheck1").val(0);
	    	   }else{
	    		   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = false;
		    	   }
	    		   $("#selectCheck1").val(1);
	    	   }
	    	   
	    	   checkShow();
	       }
		  	
		function checkShow(){
		  		var str = "";
	    	    var number = 0;
	    	    var obj = document.getElementsByName("item1");
				for(var i = 0,l = obj.length;i < l;i++){
					if(obj[i].checked){
						str += obj[i].value+",";
						number++;
					}
				}    	   
	    			
	    	    if(str == ""){
	    		   $(".show4").hide();
	    		   $('.smalltitle3 p').css('display', 'block');
	    		   $('#xiaoshoujihui').css('display', 'block');
	    	    }else{
	    	       $('.smalltitle3 p').css('display', 'none');
	    		   $(".sole_id").html(str);
	    		   $(".show4").show();
	    		   $("#number2").html(number);
	    		   $('.back2').css('display', 'none');
	    		   $('.checkok2').css('display', 'block');
			    	$('.del2').css('display', 'block');
			    	$('.shift2').css('display', 'block');
			    	$('.cclose2').css('display', 'block');
	    		   
	    	   }
		  	}
		  	 
		  </script>
		  <script>
		  	
       	function selectCheck1(){
	    	   var judge = $("#selectCheck1").val();
	    	   var objs = document.getElementsByName("item1");
			   if(judge == 1){
				   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = true;
		    	   }
				   $("#selectCheck1").val(0);
	    	   }else{
	    		   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = false;
		    	   }
	    		   $("#selectCheck1").val(1);
	    	   }
	    	   
	    	   checkedShow1();
	       }
		  	
		function checkedShow1(){
		  		var str = "";
	    	    var number = 0;
	    	    var obj = document.getElementsByName("item1");
				for(var i = 0,l = obj.length;i < l;i++){
					if(obj[i].checked){
						str += obj[i].value+",";
						number++;
					}
				}    	   
	    			
	    	    if(str == ""){
	    		   $(".show4").hide();
	    		   $('.smalltitle3 p').css('display', 'block');
	    		  $('.back2').css('display', 'block');
	    	    }else{
	    	       $('.smalltitle3 p').css('display', 'none');
	    		   $(".sole_id").html(str);
	    		   $(".show4").show();
	    		   $("#number2").html(number);
	    		   
	    	   }
		  	}
		  	 
		  </script>
        	<script>
		  	
       	function selectCheck2(){
	    	   var judge = $("#selectCheck2").val();
	    	   var objs = document.getElementsByName("item2");
			   if(judge == 1){
				   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = true;
		    	   }
				   $("#selectCheck2").val(0);
	    	   }else{
	    		   for(var i = 0,l = objs.length;i < l;i++){
		    		   objs[i].checked = false;
		    	   }
	    		   $("#selectCheck2").val(1);
	    	   }
	    	   
	    	   checkedShow2();
	       }
		  	
		function checkedShow2(){
		  		var str = "";
	    	    var number = 0;
	    	    var obj = document.getElementsByName("item2");
				for(var i = 0,l = obj.length;i < l;i++){
					if(obj[i].checked){
						str += obj[i].value+",";
						number++;
					}
				}    	   
	    			
	    	    if(str == ""){
	    		   $(".show6").hide();
	    		   $('.smalltitle4 p').css('display', 'block');
	    		   $('.back3').css('display', 'block');
	    	    }else{
	    	       $('.smalltitle4 p').css('display', 'none');
	    	       $('.back3').css('display', 'none');
	    		   $(".staff_id").html(str);
	    		   $(".show6").show();
	    		   $("#number3").html(number);
	    	   }
		  	}
		  	 
		  </script>
    </head>
    <body>
    	<div class="bigbox2 bbigbox">
    		<nav class="nnav">
    			<span class="scolor"></span>
    			<ul>
    				<li><a href="<%=basePath %>page/originalIndex.jsp"><p class="mline"><span class="smallicon"></span><span class="navtxt">首 页</span></p></a></li>
    				<li><a href="<%=basePath %>client/findByIndex.action" id="sline"><p class="mline"><span class="smallicon one1" id="current21"></span><span class="navtxt" id="current2">客 户</span></p></a></li>
    				<li><a href="<%=basePath %>sale/findSale.action"><p class="mline"><span class="smallicon one2"></span><span class="navtxt">销 售 机 会</span></p></a></li>
    				<li><a href="<%=basePath %>contact/page.action"><p class="mline"><span class="smallicon one3"></span><span class="navtxt">联 系 人</span></p></a></li>
    				<li><a href="<%=basePath %>contract/findByAlls.action"><p class="mline"><span class="smallicon one4"></span><span class="navtxt">合 同</span></p></a></li>
    				<li class="shenpi"><a href="<%=basePath %>page/pacts.jsp"><p class="mline"><span class="smallicon one8"></span><span class="navtxt">合 同 审 批</span></p></a></li>
    				<c:if test="${sessionScope.backstage == 1}">
   						<li><a href="<%=basePath %>staff/selectTree.action"><p class="mline"><span class="smallicon one5"></span><span class="navtxt">后 台 管 理</span></p></a></li>
    				</c:if>
    			</ul>
    		</nav>
    		<div class="showbox2">
	    		<p class="title">客 户</p>
	    		<div class="aaa">
	    			<div class="smalltitle">
		    			<span class="back"><&nbsp;&nbsp;&nbsp;&nbsp;负责的客户</span>
						<p class="show1">

								<a href="#" class="light3"><span class="imgmove"><img src="<%=basePath %>images/icon (14).png" alt=""></span>&nbsp;&nbsp;导出</a>
								 <a href="#" class="newkh"><span class="imgmove imgmove2"><img src="<%=basePath %>images/icon (23).png" alt=""></span>&nbsp;&nbsp;新建客户</a>
								 <a href="#"><span class="imgmove imgmove2"><img src="<%=basePath %>images/icon (16).png" alt=""></span>&nbsp;&nbsp;导入</a>
						</p>
		 				<div class="show2">
		 					<a href="#" class="smallig"><img src="<%=basePath %>images/icon (20).png" alt=""></a>
					 		<h4 class="checkok">已选择 <span style="color:#1fd4fb;" id = "number">1 </span>项</h4>
					 		<span class="del" onclick="deleteClient()"><img src="<%=basePath %>images/icon (17).png" alt="" style="position: absolute;bottom: 28px;left: -22px;">&nbsp;删除</span>
					  		<span class="del shift"><img src="<%=basePath %>images/icon (25).png" alt="" style="position: absolute;bottom: 28px;left: -29px;">&nbsp;转移</span>
	    					<span class="close2">
	    						<img src="<%=basePath %>images/icon (18).png" alt="">
	    					</span>
		 				</div> 
	    			</div>
	    			<span class="blueline"></span>
	    			<div class="tab">
	    					<p class="tline">
	    						<span class="xuanze"><input type="checkbox" class="check1" id="selectCheck" value="1" onclick="selectCheck()"></span>
			    		            <span>客户名称</span>
			    		            <span class="cname">客户所有人</span>
			    		            <span>客户级别</span>
			    		            <span class="cphone">总人数</span>
			    		            <span class="cphone">区 域</span>
			    		            <span class="cdate">电 话</span>
			    		            <span class="cdate2">创建日期</span>
	    					</p>
	    					<c:forEach items="${newClientUtils}" var="newClientUtil">
	    						<p class="tline tline2">
		    						<span class="xuanze"><input type="checkbox" class="check1" name="items" value="${newClientUtil.client.client_id}" onclick="checkedShow()"></span>
			    		            <a href="<%=basePath %>client/findByClientId.action?id=${newClientUtil.client.client_id}"><span>${newClientUtil.client.client_name}</span></a>
			    		            <span class="cname">${newClientUtil.staff}</span>
			    		            <span>${newClientUtil.rank}</span>
			    		            <span class="cphone">${newClientUtil.client.client_headcount}</span>
			    		            <span class="cphone">${newClientUtil.information.information_province}</span>
			    		            <span class="cdate">${newClientUtil.information.information_phone}</span>
			    		            <span class="cdate2"><fmt:formatDate value="${newClientUtil.communal.communal_creationDate}" type="date" /></span>
		    					</p>
	    					</c:forEach>	   
	    			</div>
	    			<div id="cover">
			    		<div id="cover-bg"></div>
						<div id="cover-content">
								<h4>新 建 客 户<span class="close"></span></h4>
								<p class="main">
									<span class="leftmain">客 户 名 称</span>
									<input type="text" id="client_name" value="" placeholder="&nbsp;&nbsp;请输入客户的姓名 " class="shurukuang shurukuang2 shurukuang22">
									<span class="xsicon xsicon2" id="chachong" onclick="selectRepeat()"><img src="../images/search.png" alt="" class="kkk kkk2">&nbsp;查重</span>
									<span id="repeatSpn" style="color: red;margin-left: 135px;font-size: 14px;margin-top: 5px;display: inline-block;"></span>
								</p>
								<p class="main">
									<span class="leftmain" >省 份&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<select id="sheng" name="province3" class="shenfenselect shenfenselect4">
							        </select>
							        <select id="shi" name="city3" class="shenfenselect shenfenselect2 shenfenselect4">
							        </select>
							        <select id="xiang" name="area3" class="shenfenselect shenfenselect2 shenfenselect4">
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">详 细 地 址</span>
									<input type="text" id="information_address" value="" placeholder="&nbsp;&nbsp;请输入详细地址 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">电 话&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_phone" value="" placeholder="&nbsp;&nbsp;请输入电话 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">备 注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_remarks" value="" placeholder="&nbsp;&nbsp;请输入备注 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">所 属 部 门</span>
									<select id="department_id" class="shenfenselect shenfenselect3">
							            <c:forEach items="${departments}" var="department">
							            	<option value="${department.department_id}">${department.department_name}</option>
							            </c:forEach>
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">客 户 级 别</span>
									<select id="rankId" class="shenfenselect shenfenselect3">
							            <c:forEach items="${ranks}" var="rank">
							            	<option value="${rank.rankId}">${rank.rankName}</option>
							            </c:forEach>
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">上 级 客 户</span>
									<input type="text" id="client_parent" value="" class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">行 业&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<select id="tradeManageId" class="shenfenselect shenfenselect3">
							            <c:forEach items="${tradeManages}" var="tradeManage">
							            	<option value="${tradeManage.tradeManageId}">${tradeManage.tradeName}</option>
							            </c:forEach>
							        </select>
								</p>
								<p class="main">
									<span class="leftmain">邮 政 编 码</span>
									<input type="text" id="information_postalcode" value="" class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">传 真&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_fax" value="" placeholder="&nbsp;&nbsp;请输入传真 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">公 司 网 址</span>
									<input type="text" id="information_website" value="" placeholder="&nbsp;&nbsp;请输入公司网址 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">微 博&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
									<input type="text" id="information_microblog" value="" placeholder="&nbsp;&nbsp;请输入微博 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">总人数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
									<input type="text" id="client_headcount" value="" placeholder="&nbsp;&nbsp;请输入总人数 " class="shurukuang">
								</p>
								<p class="main">
									<span class="leftmain">销售额（元）</span>
									<input type="text" id="client_saleroom" value="" placeholder="&nbsp;&nbsp;请输入销售额 " class="shurukuang shurukuang2">
								</p>
								<p class="main" style="text-align: center;">
									<button class="btn1 btn2" onclick="saveClient()">保存</button>
									<button class="btn1 btn3" onclick="quxiao()">取消</button>
								</p>
			    		</div>
					</div>
	    		</div>
	    		<div class="aaa">
	    			<div class="smalltitle3">
	    			 	<div class="show3">
	    			 		<span class="back2" id="xiaoshoujihui"> < 负责的销售机会</span>
	    					
	    					
	    					<p>
	    						<a href="#" class="light3"><span class="imgmove"><img src="<%=basePath %>images/icon (14).png" alt=""></span>&nbsp;&nbsp;导出</a>
	    						<a href="#" class="newsale" onclick="selectClien()"><span class="imgmove imgmove2 imgmove22"><img src="<%=basePath %>images/icon (23).png" alt=""></span>&nbsp;&nbsp;新建销售机会</a>
	    						<a href="#"><span class="imgmove imgmove2"><img src="<%=basePath %>images/icon (16).png" alt=""></span>&nbsp;&nbsp;导入</a>
	    					</p>			 
	    			 	</div>
	    				<div class="show4">
	    					<a href="#" class="smallig2"><img src="<%=basePath %>images/icon (20).png" alt=""></a>
	    					<h4 class="checkok2">已选择 <span style="color:#1fd4fb;" id="number2">1 </span>项</h4>
	    					<span class="del2" onclick="deleteSale()"><img src="<%=basePath %>images/icon (17).png" alt="" style="position: absolute;bottom: 28px;left: -22px;">&nbsp;删除</span>
	    					<span class="del2 shift2"><img src="<%=basePath %>images/icon (25).png" alt="" style="position: absolute;bottom: 28px;left: -29px;">&nbsp;转移</span>
	    					<span class="cclose2">
	    					<img src="<%=basePath %>images/icon (18).png" alt="">
	    					</span>
	    				</div> 
	    			</div>
	    			<span class="blueline"></span>
	    			<div class="tab">
	    				<p class="tline ssline2">
	    					<span class="xuanze"><input type="checkbox" class="ccheck1" id="selectCheck1" value="1" onclick="selectCheck1();"></span>
	    					<span>机会名称</span>
	    					<span class="cname">销售机会所有人</span>
	    					<span>客户名称</span>
	    					<span class="cphone">机会类型</span>
	    					<span class="cphone">销售金额</span>
	    					<span class="cdate">结单日期</span>
	    					<span class="cdate2">销售阶段</span>
	    					<span class="cdate2">创建日期</span>
	    				</p>
	    				<c:forEach items="${saleUtils}" var="list">
	    					<p class="tline tline2 sssline2">
	    					<span class="xuanze"><input type="checkbox" value="${list.sale.saleId}" class="ccheck1" name="item1" onclick="checkShow()"></span>
	    					<a href="<%=basePath %>sale/findSaleId.action?pageSize=4&pageNum=1&id=${list.sale.saleId}"><span>${list.sale.saleOpportunityName}</span></a>
	    					<span class="cphone">${list.staff}</span>
	    					<span class="cphone">${list.client}</span>
	    					<span>${list.sale.saleOpportunitytype}</span>
	    					<span class="cphone">${list.sale.saleMoney}</span>
	    					<span class="cdate"><fmt:formatDate value="${list.sale.saleCloseDate}" pattern="yy-MM-dd"/></span>
	    					<span class="cphone">${list.salestage}</span>
	    					<span class="cphone"><fmt:formatDate value="${list.sale.createDate}" pattern="yy-MM-dd"/></span>
	    				</p>
	    				</c:forEach>		
	    			</div>
	    			<div id="cover3">
								<div id="cover-bg2"></div>
								<form action="<%=basePath %>client/saveSale.action" method="post" onsubmit="">
									<div id="cover-content2">
												<h4>新 建 销 售 机 会<span class="close"></span></h4>
												<p class="main">
													<span class="leftmain">机 会 名 称</span>
													<input type="text" name="saleOpportunityName" placeholder="&nbsp;&nbsp;请输入机会名称 " class="shurukuang">
												</p>
												<p class="main">
													<span class="leftmain">客 户 名 称</span>
													 <select  id="kehumingcheng" name="clientId"  class="shenfenselect shenfenselect3">
											            
											        </select>
												</p>
												<p class="main">
													<span class="leftmain">销 售 金 额</span>
													<input type="text" name="saleMoney" placeholder="&nbsp;&nbsp;请输入销售金额 " class="shurukuang">
												</p>
												<p class="main">
													<span class="leftmain">销 售 阶 段</span>
													<select name="salestageId" id="one" class="shenfenselect shenfenselect3">
											            <c:forEach items="${salestages}" var="salestage">
											            	<option value="${salestage.saleStageId}">${salestage.saleStageName}</option>
											            </c:forEach>
											        </select>
												</p>
												<p class="main">
													<span class="leftmain">结 单 日 期</span>
													<input type="text" name="saleCloseDate" id="saleCloseDate" placeholder="&nbsp;&nbsp;请输入结单日期 " class="shurukuang Wdate" style="height: 30px;1px solid #bfbfbf;"   onfocus="WdatePicker({skin:'whyGreen',dateFmt: 'yyyy-MM-dd', readOnly:true})">
												
												</p>
												<p class="main">
													<span class="leftmain">备 注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
													<input type="text" name="saleRemark" placeholder="&nbsp;&nbsp;请输入备注 " class="shurukuang">
												</p>
												<p class="main">
													<span class="leftmain">所 属 部 门</span>
													<select id="one" name="departmentId" class="shenfenselect shenfenselect3">
											            <c:forEach items="${departments}" var="department">
											            	<option value="${department.department_id}">${department.department_name}</option>
											            </c:forEach>
											        </select>
												</p>
												<p class="main">
													<span class="leftmain">市场活动</span>
													<span class="none">该公司没有活动</span>
												</p>
												<p class="main">
													<span class="leftmain">机 会 类 型</span>
													<select id="one" name="saleOpportunitytype" class="shenfenselect shenfenselect3">
											            <option value="">请选择机会类型</option>
											            <option value="新客户机会">新客户机会</option>
											            <option value="老客户机会">老客户机会</option>
											        </select>
												</p>
												<p class="main">
													<span class="leftmain">机 会 来 源</span>
													<select id="one" name="sourceId" class="shenfenselect shenfenselect3">
											            <c:forEach items="${sources}" var="sources">
											            	<option value="${sources.sourceId}">${sources.sourceName}</option>
											            </c:forEach>
											        </select>
												</p>
												
												<p class="main" style="text-align: center;">
													<input type="submit" value="保存" class="btn1 btn2" style="text-align: center;">
													<input type="reset" value="清空" class="btn1 btn3" style="text-align: center;">
												</p>
												
										</div>
									</form>
	    			</div>
	    		</div>
	    		<div class="aaa">
		    		<div class="smalltitle4">
		    			<div class="show5">
		    					<span class="back3"><&nbsp;&nbsp;&nbsp;&nbsp;负责的合同</span>
			    				<p>
			    				    <a href="#" class="light3"><span class="imgmove"><img src="<%=basePath %>images/icon (14).png" alt=""></span>&nbsp;&nbsp;导出</a>
			    				    <a href="#" class="newht" onclick="updateStaffName()"><span class="imgmove imgmove2"><img src="<%=basePath %>images/icon (23).png" alt=""></span>&nbsp;&nbsp;新建合同</a>
			    				    <a href="#"><span class="imgmove imgmove2"><img src="<%=basePath %>images/icon (16).png" alt=""></span>&nbsp;&nbsp;导入</a>
			    				</p>
		    			</div>
		    			<a href="#" class="smallig2"><img src="<%=basePath %>images/icon (20).png" alt=""></a>
		    			<div class="show6">
		    			 	<h4 class="checkok3">已选择 <span style="color:#1fd4fb;" id="number3">1 </span>项</h4>
		    			 	<span class="del3" onclick="deleteContract()"><img src="<%=basePath %>images/icon (17).png" alt="" style="position: absolute;bottom: 28px;left: -22px;" >&nbsp;删除</span>
		    			 	<span class="del3 shift3"><img src="<%=basePath %>images/icon (25).png" alt="" style="position: absolute;bottom: 28px;left: -29px;">&nbsp;转移</span>
		    			 	<span class="close4">
		    			 		<img src="<%=basePath %>images/icon (18).png" alt="">
		    			 	</span>
		    			 </div>	 
		    		</div>
	    			<span class="blueline"></span>
	    			<div class="tab">
	    				<p class="tline">
	    					<span class="xuanze"><input type="checkbox"  class="check3" id="selectCheck2" value="1" onclick="selectCheck2()" ></span>
	    					<span>客户姓名</span>
	    					<span class="cname">合同类型</span>
	    					<span>开始日期</span>
	    					<span class="cphone">总金额</span>
	    					<span class="cphone">付款方式</span>
	    					<span class="cdate">合同状态</span>
	    					<span class="cdate2">合同所有人</span>
	    				</p>
	    				<c:forEach items="${contracts}" var="contract">
	    					<p class="tline tline2">
		    					<span class="xuanze"><input type="checkbox" value="${contract.contractId}" id="" class="check3" name="item2" onclick="checkedShow2()"></span>
		    					<span><a href="<%=basePath %>contract/selectById.action?id=${contract.contractId}" style="font-size: 14px;text-decoration:none;color:#000">${contract.clientName}</a></span>
		    					<span class="cname">${contract.contracttype }</span>
		    					<span><fmt:formatDate value="${contract.contractCloseDate}" type="date"/></span>
		    					<span class="cphone">${contract.contractAmount}</span>
		    					<span class="cphone">${contract.contractPaymode}</span>
		    					<span class="cdate">${contract.contractStatus}</span>
		    					<span class="cdate2">${contract.staffName}</span>
		    				</p>	
	    				</c:forEach>	    
	    			</div>
	    			<div id="cover4">
	    					<div id="cover-bg3"></div>
	    					<div id="cover-content3">
										<h4>新 建 合 同<span class="close"></span></h4>
										<p class="main">
											<span class="leftmain">业务类型</span>
											
											
											<span class="name" id="contractBusinesstype">默认业务类型</span>
											
										</p>
										<p class="main">
											<span class="leftmain">主 题&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
											<input type="text" id="contractTitle" placeholder="&nbsp;&nbsp;请输入主题 " class="shurukuang">
										</p>
										
										
										<p class="main">
											<span class="leftmain">客 户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
											<select id="onecli" class="shenfenselect shenfenselect3" onchange="selectSale()">
									           
									        </select>
										</p>
										<p class="main">
											<span class="leftmain">销 售 机 会</span>
											<select id="saleId" class="shenfenselect shenfenselect3">
									        </select>
										</p>
										<p class="main">
											<span class="leftmain">总 金 额&nbsp;&nbsp;&nbsp;&nbsp;</span>
											<input type="text" id="contractAmount" placeholder="&nbsp;&nbsp;请输入总金额 " class="shurukuang">
										</p>
										<p class="main">
											<span class="leftmain">付 款 方 式</span>
											<select id="onecli" class="shenfenselect shenfenselect3">
									            <option>&nbsp;支票</option>
									            <option>&nbsp;现金</option>
									            <option>&nbsp;银行转账</option>
									            <option>&nbsp;其他</option>
									           
									        </select>
										</p>
										<p class="main">
											<span class="leftmain">开 始 日 期</span>
											<input type="text" id="contractStartDate" placeholder="&nbsp;&nbsp;请输入开始日期 " class="shurukuang Wdate" style="height: 30px;1px solid #bfbfbf;"   onfocus="WdatePicker({skin:'whyGreen',dateFmt: 'yyyy-MM-dd', readOnly:true})">
											
										</p>
										<p class="main">
											<span class="leftmain">结 束 日 期</span>
											<input type="text" id="contractCloseDate" class="shurukuang Wdate" style="height: 30px;1px solid #bfbfbf;" placeholder="&nbsp;&nbsp;请输入结束日期 "  onfocus="WdatePicker({skin:'whyGreen',dateFmt: 'yyyy-MM-dd', readOnly:true})">
											
											
										</p>
										
										<p class="main">
											<span class="leftmain">签 约  日 期</span>
											<input type="text" id="contractSigndate" placeholder="&nbsp;&nbsp;请输入签约日期 " class="shurukuang Wdate" style="height: 30px;1px solid #bfbfbf;"   onfocus="WdatePicker({skin:'whyGreen',dateFmt: 'yyyy-MM-dd', readOnly:true})">
											
										</p>
										<p class="main">
											<span class="leftmain">合 同 所 有 人</span>
											<span class="none" id="staff_name"></span>
										</p>
										
										<p class="main">
											<span class="leftmain">合 同 编 号</span>
											<input type="text" id="contractCode" placeholder="&nbsp;&nbsp; " class="shurukuang">
										</p>
										
										<p class="main">
											<span class="leftmain">合 同 正 文</span>
											<textarea rows="" cols="" id="contractContent" cols="30" rows="10"></textarea>
										</p>
										
										<p class="main">
											<span class="leftmain">产 品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
											<input type="text" id="contractProduct" placeholder="&nbsp;&nbsp; " class="shurukuang">
										</p>
										
										<p class="main">
											<span class="leftmain">我 方 签 约 人</span>
											<input type="text" id="contractSigner" placeholder="&nbsp;&nbsp; " class="shurukuang">
										</p>
										
										<p class="main">
											<span class="leftmain">我客户方签约人</span>
											<input type="text" id="contractCustomerSigner" placeholder="&nbsp;&nbsp; " class="shurukuang">
										</p>
										
										<p class="main">
											<span class="leftmain">所 属 部 门</span>
											<select id="onedeps" class="shenfenselect shenfenselect3">
									            <option>请选择</option>
									            
									        </select>
										</p>
										
										<p class="main">
											<span class="leftmain">合 同 类 型</span>
											<select id="onecees" class="shenfenselect shenfenselect3">
									            <option>&nbsp;请选择合同类型</option>
									            
									        </select>
										</p>
										
										<p class="main">
											<span class="leftmain">合 同 状 态</span>
											<select id="contractStatus" class="shenfenselect shenfenselect3">
									            <option>&nbsp;请选择合同状态</option>
									            <option>&nbsp;执行中</option>
									            <option>&nbsp;结束</option>
									            <option>&nbsp;意外终止</option>
									            
									        </select>
										</p>
										<p class="main">
											<span class="leftmain">签 约 备 注</span>
											<input type="text" value="" id="contractSignremarks" class="shurukuang">
										</p>
										
										<p class="main" style="text-align: center;">
											
											<button class="btn1 btn2" onclick="saveContract()">保存</button>
											<button class="btn1 btn3">取消</button>
										</p>
						</div>
	    			</div>
	    		</div>
	    	</div> 
    		
    	</div>
    	<div style="display: none">
    		<p class="staff_id"></p>       
    		<p class="client_id"></p>       
    		<p class="sole_id"></p>   
    	</div>    
    	      <script src="${pageContext.request.contextPath}/salejihui/My97DatePicker/WdatePicker.js"></script>
    </body>
    <script type="text/javascript">
	    function deleteContract(){
		  	var staff_id = $(".staff_id").html();
		  	staff_id = staff_id.substring(0,staff_id.length-1);
		  	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/deletes.action",
				data:"ids="+staff_id,
				success:function(data){
					alert(data);
					location.href="<%=basePath %>client/findByIndex.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}
	
	   		 });
		}
	    function deleteClient(){
		  	var client_id = $(".client_id").html();
		  	client_id = client_id.substring(0,client_id.length-1);
		  	$.ajax({
				type:"post",
				url:"<%=basePath %>client/deletes.action",
				data:"ids="+client_id,
				success:function(data){
					alert(data);
					location.href="<%=basePath %>client/findByIndex.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}
	
	   		 });
		}
	    function deleteSale(){
		  	var sole_id = $(".sole_id").html();
		  	sole_id = sole_id.substring(0,sole_id.length-1);
		  	$.ajax({
				type:"post",
				url:"<%=basePath %>sale/deleteManyId.action",
				data:"delid="+sole_id,
				success:function(data){
					alert(data);
					location.href="<%=basePath %>client/findByIndex.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}
	
	   		 });
		}
	    
	    function saveContract(){
	    	var onecli = $("#kehumingcheng option:selected").val();
	    	if(onecli == 0){
	    		alert("客户不能为空");
	    		return;
	    	}
	    	var contractBusinesstype = "默认业务类型";
	    	var saleI = $("#saleId option:selected").val();
	    	var contractTitle = $("#contractTitle").val();
	    	var contractAmoun = $("#contractAmount").val();
	    	var onecl = $("#onecli").val();
	    	var contractStartDat = $("#contractStartDate").val();
	    	var contractCloseDat = $("#contractCloseDate").val();
	    	var contractSigndate = $("#contractSigndate").val();
	    	var contractContent = $("#contractContent").val();
	    	var staff_name= $("#staff_name").html();
	    	var contractCod = $("#contractCode").val();
	    	var contractProduc = $("#contractProduct").val();
	    	var contractSigne = $("#contractSigner").val();
	    	var contractCustomerSigne = $("#contractCustomerSigner").val();
	    	var onedep = $("#onedeps").find("option:selected").text();
	    	var onecee = $("#onecees").find("option:selected").text();
	    	var contractStatu = $("#contractStatus").find("option:selected").text();
	    	var remark = $("#contractSignremarks").val();
	    	var usdata = {contractBusinesstype:contractBusinesstype,clientName:onecli,saleId:saleI,
	    				  contractTitle:contractTitle,contractAmount:contractAmoun,contractPaymode:onecl,
	    				  contractStartDate:contractStartDat,contractCloseDate:contractCloseDat,staffName:staff_name,
	    				  contractCode:contractCod,contractProduct:contractProduc,contractSigner:contractSigne,contractCustomerSigner:contractCustomerSigne,
	    				  departmentName:onedep,contracttype:onecee,contractStatus:contractStatu,contractSigndate:contractSigndate,
	    				  contractContent:contractContent,contractSignremark:remark};
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/saveContract.action",
				data:usdata,
				success:function(data){
					alert(data);
					if(data == "新增成功"){
						location.href="<%=basePath %>client/findByIndex.action";
					}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
	    }
	    function updateStaffName(){
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/findCompactGenres.action",
				success:function(data){
					$("#onecees").html("");
		    	    var baa = "<option value=''>请选择</option>";
		    	    $("#onecees").append(baa);
					var dep = eval("("+data+")");
						for(var i=0;i<dep.length;i++){
							var depar = dep[i];
							var depass = "<option value='"+depar.compactName+"'>"+depar.compactName+"</option>";
							$("#onecees").append(depass);
						}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
					location.href="<%=basePath %>client/findByIndex.action";
				}

	   		 });
	    	
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>staff/findAllDeps.action",
				success:function(data){
					$("#onedeps").html("");
		    	    var baa = "<option value=''>请选择</option>";
		    	    $("#onedeps").append(baa);
					var dep = eval("("+data+")");
					for(var i=0;i<dep.length;i++){
						var depar = dep[i];
						var depass = "<option value='"+depar.department_id+"'>"+ depar.department_name+"</option>";
						$("#onedeps").append(depass);
					}
					$.ajax({
						type:"post",
						url:"<%=basePath %>contract/findStaffSession.action",
						success:function(staffs){
							var staff = eval("("+staffs+")");
							$("#staff_name").html(staff[0].staff_name);
							$("#onedeps option[value='"+staff[0].staff_departmentId+"']").attr("selected",true);
						},
						error:function(e){
							alert("发生未知错误请刷新页面");
							location.href="<%=basePath %>client/findByIndex.action";
						}
			   		 });
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
					location.href="<%=basePath %>client/findByIndex.action";
				}
	   		 });
	    	
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/findClients.action",
				success:function(data){
					$("#onecli").html("");
		    	    var baa = "<option value='0'>请选择</option>";
		    	    $("#onecli").append(baa);
					var dep = eval("("+data+")");
						for(var i=0;i<dep.length;i++){
							var depar = dep[i];
							var depass = "<option value='"+depar.client_id+"'> "+ depar.client_name+"</option>";
							$("#onecli").append(depass);
						}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
					location.href="<%=basePath %>client/findByIndex.action";
				}

	   		 });
	    	
	    }
	    function saveClient(){
	    	
	    	var client_name = $("#client_name").val();
	    	var sheng = $("#sheng option:selected").val();
	    	var shi = $("#shi option:selected").val();
	    	var xiang = $("#xiang option:selected").val();
	    	var information_province = null;
	    	var information_city = null;
	    	var information_area = null;
	    	if(sheng != ""){
	    		information_province = sheng;
	    		information_city = shi;
		    	information_area = xiang;
	    	}
	    	var department_id = $("#department_id option:selected").val();
	    	var rankID = $("#rankId option:selected").val();
	    	var information_address = $("#information_address").val();
	    	var information_phone = $("#information_phone").val();
	    	var information_remarks = $("#information_remarks").val();
	    	var client_parent = $("#client_parent").val();
	    	var vocationID = $("#vocationID option:selected").val();
	    	var information_postalcode = $("#information_postalcode").val();
	    	var information_fax = $("#information_fax").val();
	    	var information_website = $("#information_website").val();
	    	var information_microblog = $("#information_microblog").val();
	    	var client_headcount = $("#client_headcount").val();
	    	var client_saleroom = $("#client_saleroom").val();
	    	var usdata = {information_province:information_province,
	    			client_name:client_name,information_province:information_province,departmentID:department_id,
	    			rankID:rankID,information_address:information_address,information_phone:information_phone,information_remarks:information_remarks,
	    			client_parent:client_parent,vocationID:vocationID,information_postalcode:information_postalcode,
	    			information_fax:information_fax,information_website:information_website,information_microblog:information_microblog,
	    			client_headcount:client_headcount,client_saleroom:client_saleroom,information_city:information_city,information_area:information_area};
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>client/save.action",
				data:usdata,
				success:function(data){
					alert(data);
					if(data == "新增成功"){
						location.href="<%=basePath %>client/findByIndex.action";
					}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
					location.href="<%=basePath %>client/findByIndex.action";
				}
	
	   		 });
	    }
	    
	    function updateStaffName(){
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/findCompactGenres.action",
				success:function(data){
					$("#onecees").html("");
		    	    var baa = "<option value=''>请选择</option>";
		    	    $("#onecees").append(baa);
					var dep = eval("("+data+")");
						for(var i=0;i<dep.length;i++){
							var depar = dep[i];
							var depass = "<option value='"+depar.compactName+"'>"+depar.compactName+"</option>";
							$("#onecees").append(depass);
						}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
	    	
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>staff/findAllDeps.action",
				success:function(data){
					$("#onedeps").html("");
		    	    var baa = "<option value=''>请选择</option>";
		    	    $("#onedeps").append(baa);
					var dep = eval("("+data+")");
					for(var i=0;i<dep.length;i++){
						var depar = dep[i];
						var depass = "<option value='"+depar.department_id+"'>"+ depar.department_name+"</option>";
						$("#onedeps").append(depass);
					}
					$.ajax({
						type:"post",
						url:"<%=basePath %>contract/findStaffSession.action",
						success:function(staffs){
							var staff = eval("("+staffs+")");
							$("#staff_name").html(staff[0].staff_name);
							$("#onedeps option[value='"+staff[0].staff_departmentId+"']").attr("selected",true);
						},
						error:function(e){
							alert("发生未知错误请刷新页面");
						}
			   		 });
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}
	   		 });
	    	
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/findClients.action",
				success:function(data){
					$("#onecli").html("");
		    	    var baa = "<option value='0'>请选择</option>";
		    	    $("#onecli").append(baa);
					var dep = eval("("+data+")");
						for(var i=0;i<dep.length;i++){
							var depar = dep[i];
							var depass = "<option value='"+depar.client_id+"'> "+ depar.client_name+"</option>";
							$("#onecli").append(depass);
						}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
	    	
	    }
	    function selectSale(){
	    	var id = $("#onecli").val();
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/findxiaoshoujihui.action",
				data:"id="+id,
				success:function(data){
					$("#saleId").html("");
					var dep = eval("("+data+")");
					for(var i=0;i<dep.length;i++){
						var depar = dep[i];
						var depass = "<option value='"+depar.saleId+"'> "+ depar.saleOpportunityName+"</option>";
						$("#saleId").append(depass);
					}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
	    }
	    
	    function selectClien(){
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>contract/findClients.action",
				success:function(data){
					$("#kehumingcheng").html("");
					var dep = eval("("+data+")");
					var baa = "<option value='0'>请选择</option>";
		    	    $("#kehumingcheng").append(baa);
						for(var i=0;i<dep.length;i++){
							var depar = dep[i];
							var depass = "<option value='"+depar.client_id+"'> "+ depar.client_name+"</option>";
							$("#kehumingcheng").append(depass);
						}
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
	    }
	    function selectRepeat(){
	    	var clientName = $("#client_name").val();
	    	if(clientName == ""){
	    		$("#repeatSpn").html("请输入客户名称");
	    		return;
	    	}
	    	$.ajax({
				type:"post",
				url:"<%=basePath %>client/selectRea.action",
				data:"client_name="+clientName,
				success:function(data){
					$("#repeatSpn").html(data);
				},
				error:function(e){
				}

	   		 });
	    }
    </script>
    <script type="text/javascript" defer>
    	new PCAS("province3","city3","area3");
    </script>
</html>
